<template>
    <div class="root">
        <div class="login-box">
            <div class="login-content">
                <div class="login-title">后台管理系统登录</div>
                <div class="form-box">
                    <input class="base-input" type="text" v-model="formInfo.username" placeholder="用户名">
                    <input class="base-input" type="password" v-model="formInfo.password" placeholder="密码">
                    <input class="base-button" type="button" value="登录" @click="login">
                    <div class="other">
                        <!--<div>忘记密码</div>-->
                        <router-link style="outline: none; text-decoration: none" to="/register">注册
                        </router-link>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>

import {useRouter} from 'vue-router';
import {ref} from 'vue';
import { useUserStore } from "@/store/index.js";

const router = useRouter()
const userStore = useUserStore()

let formInfo = ref({
    username: '',
    password: ''
})

function login() {
    userStore.login(formInfo.value);
}
</script>

<style scoped lang="scss">
.root {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-image: linear-gradient(to top, #cfd9df 0%, #e2ebf0 100%);
    //background-image: url('@/assets/imgs/loginbg.jpg');

    .login-box {
        width: 400px;
        height: 280px;
        padding: 20px;
        background: white;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        border-radius: 8px;
        text-align: center;
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);

        .login-content {
            //margin: 30px;
            box-sizing: border-box;
            display: flex;
            flex-direction: column;
            align-items: center;

            .login-title {
                font-size: 23px;
                margin: 20px 0;
                color: #324038;
                font-weight: bold;
            }

            .form-box {
                display: flex;
                flex-direction: column;
                margin: 15px 0;

                .base-input {
                    margin-bottom: 10px;
                    padding: 10px;
                    border: 1px solid #ccc;
                    border-radius: 4px;
                    outline-color: #d5d5d5;
                    font-size: 16px;
                }

                .base-button {
                    width: 300px;
                    height: 35px;
                    margin: 13px 0;
                    background-color: #1f90d1;
                    color: #ffffff;
                    border: none;
                    border-radius: 5px;
                    font-size: 16px;

                    &:hover {
                        background-color: #34a5e6;
                        color: #e7e2e2;
                    }

                    &:active {
                        background-color: #156da1;
                        color: #d3cece;
                    }

                    transition: all 0.2s;
                    cursor: pointer;
                }

                .other {
                    display: flex;
                    justify-content: flex-end;

                    > * {
                        margin-left: 10px;
                        cursor: pointer;
                        color: #4e4e4e;

                        &:hover {
                            color: #606060;
                        }

                        &:active {
                            color: #040404;
                        }

                        transition: all 0.2s;
                        font-size: 14px;
                    }
                }
            }
        }
    }
}
</style>
